package com.training.collection.section5;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

public class IteratorDemo {

	public static void main(String[] args) {
		List<Integer> list = new ArrayList<>();
		
		for(int i = 1; i < 100; i ++) {
			list.add(i);
		}
		System.out.println("-----for-----");
		for(int i = 0; i < list.size(); i ++) {
			System.out.print(list.get(i)+"\t");
		}
		System.out.println("\n---foreach---");
		for(int t:list) {
			System.out.print(t+"\t");
		}
		
		System.out.println("\n---iteratior---");
		Iterator<Integer>it = list.iterator();
		while(it.hasNext()) {
			System.out.print(it.next()+"\t");
		}

	}

}
